// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import FastClick from 'fastclick'
import MintUI from 'mint-ui'
import 'mint-ui/lib/style.css'
import VueScroller from 'vue-scroller'
import vueScrollBehavior from 'vue-scroll-behavior'
import {fetchPost,fetchGet,getAll} from './config/httpConfig'

Vue.config.productionTip = false
Vue.prototype.$fetchPost =fetchPost
Vue.prototype.$fetchGet =fetchGet
Vue.prototype.$getAll =getAll
Vue.use(VueScroller)//上拉加载，下拉刷新
//弹框
import  { AlertPlugin,Alert,ConfirmPlugin,LoadingPlugin,ToastPlugin} from 'vux'
Vue.use(AlertPlugin)
Vue.use(ConfirmPlugin)
Vue.use(LoadingPlugin)
Vue.use(ToastPlugin)
Vue.use(vueScrollBehavior, { router: router })
if ('addEventListener' in document) {
    document.addEventListener('DOMContentLoaded', function() {
        FastClick.attach(document.body);
    }, false);
}
Vue.filter("filterTime",function(val){
	  let h=new Date(val).getHours()>=10?new Date(val).getHours():'0'+new Date(val).getHours();
	  let ms=new Date(val).getMinutes()>=10?new Date(val).getMinutes():'0'+new Date(val).getMinutes();
	  let s=new Date(val).getSeconds()>=10?new Date(val).getSeconds():'0'+new Date(val).getSeconds();
	  return h+":"+ms;
})
Vue.filter("filterTimes",function(val){
	  let y=new Date(val).getFullYear();
	  let m=new Date(val).getMonth()+1>=10?new Date(val).getMonth()+1:'0'+(new Date(val).getMonth()+1);
	  let d=new Date(val).getDate()>=10?new Date(val).getDate():'0'+new Date(val).getDate();
	  return y+"-"+m+"-"+d;
})
Vue.filter("filterTimess",function(val){
	  let y=new Date(val).getFullYear();
	  let m=new Date(val).getMonth()+1>=10?new Date(val).getMonth()+1:'0'+(new Date(val).getMonth()+1);
	  let d=new Date(val).getDate()>=10?new Date(val).getDate():'0'+new Date(val).getDate();
	  let h=new Date(val).getHours()>=10?new Date(val).getHours():'0'+new Date(val).getHours();
	  let ms=new Date(val).getMinutes()>=10?new Date(val).getMinutes():'0'+new Date(val).getMinutes();
	  let s=new Date(val).getSeconds()>=10?new Date(val).getSeconds():'0'+new Date(val).getSeconds();
	  return y+"-"+m+"-"+d+" "+h+":"+ms+":"+s;
})
Vue.filter("filterTimesss",function(val){
	  let y=new Date(val).getFullYear();
	  let m=new Date(val).getMonth()+1>=10?new Date(val).getMonth()+1:'0'+(new Date(val).getMonth()+1);
	  let d=new Date(val).getDate()>=10?new Date(val).getDate():'0'+new Date(val).getDate();
	  let h=new Date(val).getHours()>=10?new Date(val).getHours():'0'+new Date(val).getHours();
	  let ms=new Date(val).getMinutes()>=10?new Date(val).getMinutes():'0'+new Date(val).getMinutes();
	  return y+"-"+m+"-"+d+" "+h+":"+ms;
})
Vue.filter("filterTimes1",function(val){
	  let y=new Date(val).getFullYear();
	  let m=new Date(val).getMonth()+1>=10?new Date(val).getMonth()+1:'0'+(new Date(val).getMonth()+1);
	  let d=new Date(val).getDate()>=10?new Date(val).getDate():'0'+new Date(val).getDate();
	  let h=new Date(val).getHours()>=10?new Date(val).getHours():'0'+new Date(val).getHours();
	  let ms=new Date(val).getMinutes()>=10?new Date(val).getMinutes():'0'+new Date(val).getMinutes();
	  return m+"-"+d+" "+h+":"+ms;
})
Vue.filter("filterTime5",function(val){
	  let y=new Date(val).getFullYear();
	  let m=new Date(val).getMonth()+1>=10?new Date(val).getMonth()+1:'0'+(new Date(val).getMonth()+1);
	  let d=new Date(val).getDate()>=10?new Date(val).getDate():'0'+new Date(val).getDate();
	  if(y==new Date().getFullYear()){
	  	return m+'-'+d;
	  }else{
	  	return y+"-"+m+'-'+d;
	  }
})
Vue.filter("fiterPhone",function(val){
	  if(!Number(val)){
	  	if(val.length<=2){
	  		return val.slice(0,1)+"*"
	  	}else{
	  		return val.slice(0,1)+"**"+val.slice(val.length-1,val.length)
	  	}
	  }
	  if(val.length<11||val.length>11){
	  	return val;
	  }
	  let str=val.slice(0,3)+'****'+val.slice(7,11)
	  return str;
})
Vue.filter("fiterPhone1",function(val){
	  if(!Number(val)){
	  	return val;
	  }
	  if(val.length<11||val.length>11){
	  	return val;
	  }
	  let str=val.slice(0,3)+'****'+val.slice(7,11)
	  return str;
})
// 对订单号的过滤
Vue.filter("filterOrderNo",function(val){
	  let str=val.slice(0,3)+'***'+val.slice(6);
	  return str;
})
//数字两位过滤器
Vue.filter('filterNum',function(num){
	return num>=10?num:'0'+num;
})
//保留两位小数，不四舍五入
Vue.filter('keepTwoDot',function(num){
	return Math.floor(num * 100) / 100;
})
Vue.filter('filterMoney',function(num){
	return String(Number(num).toFixed(2)).split('.')[0];
})
Vue.filter('filterMoney1',function(num){
	return String(Number(num).toFixed(2)).split('.')[1];
})
 // window.getIps = "http://carnt.carnettong.com:8088";
//window.getIps = "http://4scafe.carnettong.com";
window.getIps = "http://192.168.0.123";
Vue.use(MintUI);
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  template: '<App/>',
  components: { App }
})
